package com.shujia.zookeeper;

import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.ZooDefs;
import org.apache.zookeeper.ZooKeeper;

public class Demo1ZkAPI {
    public static void main(String[] args) throws Exception {

        //创建zk连接
        ZooKeeper zooKeeper = new ZooKeeper("master:2181,node1:2181,node2:2181", 30000, null);

        zooKeeper.create(
                "/test2",
                "java".getBytes(),
                ZooDefs.Ids.OPEN_ACL_UNSAFE,
                CreateMode.PERSISTENT
        );


        //关闭连接
        zooKeeper.close();

    }
}
